﻿
using Loogn.OrmLite;
using Stardust.Common.Enum;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Stardust.ConfigCenterWeb.Code.Entities
{
    public class ServerNode
    {
        public long Id { get; set; }
        [OrmLiteField(UpdateIgnore = true)]
        public string ServiceName { get; set; }
        public string Address { get; set; }
        public string Version { get; set; }
        public ServerNodeStatus Status { get; set; }
        public double Weight { get; set; }

        [OrmLiteField(UpdateIgnore = true)]
        public DateTime HeartbeatTime { get; set; }

        public string GetStardustUrl(string servicePath = "")
        {
            if (string.IsNullOrEmpty(servicePath))
            {
                return "http://" + Address + "/stardust";
            }
            else
            {
                return "http://" + Address + "/stardust" + servicePath;
            }
        }
    }
}
